<template>
  <div class="home-page">
    <AppHeader />
    <!-- Banner -->
    <section class="banner">
      <div class="banner-left">
        <h1>让每个需求都能得到满足</h1>
        <p class="desc">无论是买卖物品、解决问题、寻求服务，还是物品交换，在这里都能找到最佳解决方案</p>
        <div class="banner-btns">
          <el-button type="primary" size="large" @click="$router.push('/publish')">我要提供需求</el-button>
          <el-button type="success" size="large" @click="$router.push('/market')" style="margin-left: 16px"
            >我要解决需求</el-button
          >
        </div>
      </div>
      <div class="banner-right">
        <img src="@/assets/test.png" alt="banner" class="banner-img" />
      </div>
    </section>

    <!-- 热门需求分类 -->
    <section class="section">
      <h2 class="section-title">热门需求分类</h2>
      <div class="category-list">
        <div v-for="cat in categories" :key="cat.title" class="category-card">
          <img :src="cat.img" :alt="cat.title" class="cat-img-large" />
          <div class="cat-title">{{ cat.title }}</div>
          <div class="cat-desc">{{ cat.desc }}</div>
        </div>
      </div>
    </section>

    <!-- 最新需求 -->
    <section class="section">
      <h2 class="section-title">最新需求</h2>
      <div class="demand-list">
        <div v-for="item in latestDemands" :key="item.id" class="demand-card">
          <img :src="item.img" :alt="item.title" class="demand-img-large" />
          <div class="demand-info">
            <div class="demand-title">{{ item.title }}</div>
            <div class="demand-desc">{{ item.desc }}</div>
            <div class="demand-meta">
              <span class="demand-price">￥{{ item.price }}</span>
              <span class="demand-time">{{ item.time }}</span>
            </div>
          </div>
        </div>
      </div>
    </section>

    <!-- 页脚 -->
    <footer class="footer">
      <div class="footer-main">
        <div class="footer-col">
          <div class="footer-title">关于我们</div>
          <div class="footer-link">公司介绍</div>
          <div class="footer-link">服务条款</div>
          <div class="footer-link">隐私政策</div>
        </div>
        <div class="footer-col">
          <div class="footer-title">帮助中心</div>
          <div class="footer-link">常见问题</div>
          <div class="footer-link">用户指南</div>
          <div class="footer-link">联系客服</div>
        </div>
        <div class="footer-col">
          <div class="footer-title">商务合作</div>
          <div class="footer-link">广告投放</div>
          <div class="footer-link">渠道合作</div>
        </div>
        <div class="footer-col">
          <div class="footer-title">关注我们</div>
          <div class="footer-link">微信公众号</div>
          <div class="footer-link">微博官方号</div>
          <div class="footer-link">企业邮箱</div>
        </div>
      </div>
      <div class="footer-copy">© 2024 必应. All rights reserved.</div>
    </footer>
  </div>
</template>

<script setup>
import { ref } from "vue";
import { useRoute, useRouter } from "vue-router";
import AppHeader from "@/components/AppHeader.vue";
const route = useRoute();
const router = useRouter();
const activeMenu = ref(route.path);
function onMenuSelect(index) {
  router.push(index);
}

const categories = [
  {
    title: "物品买卖",
    desc: "二手交换，全新商品，限量收藏品等",
    img: "/src/assets/test.png",
  },
  {
    title: "问题咨询",
    desc: "学习辅导、技术支持、生活咨询等",
    img: "/src/assets/test.png",
  },
  {
    title: "服务委托",
    desc: "代购服务、家政服务、专业服务等",
    img: "/src/assets/test.png",
  },
  {
    title: "物品交换",
    desc: "以物换物，资源互换，技能交换等",
    img: "/src/assets/test.png",
  },
];

const latestDemands = [
  {
    id: 1,
    title: "寻找 Python 开发工程师",
    desc: "需要一名有经验的 Python 开发工程师协助开发数据分析模块",
    price: 15000,
    time: "3 小时前",
    img: "/src/assets/test.png",
  },
  {
    id: 2,
    title: "收购二手 MacBook Pro",
    desc: "寻求 2023 款 MacBook Pro，配置要求 32G 内存以上",
    price: 12000,
    time: "5 小时前",
    img: "/src/assets/test.png",
  },
  {
    id: 3,
    title: "需要宠物寄养服务",
    desc: "出差期间需要照看一只成年金毛，时间约2周",
    price: 2000,
    time: "8 小时前",
    img: "/src/assets/test.png",
  },
];
</script>

<style scoped>
.home-page {
  background: #f7f9fb;
  min-height: 100vh;
}
.nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 40px;
  height: 64px;
  background: #fff;
  border-bottom: 1px solid #f0f0f0;
}
.logo {
  font-size: 22px;
  font-weight: bold;
  color: #1976d2;
  letter-spacing: 2px;
}
.slogan {
  font-size: 14px;
  color: #666;
  margin-left: 12px;
  font-weight: normal;
}
.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #eaf2fd;
  height: 400px;
  max-width: 1200px;
  margin: 0 auto;
  border-radius: 0 0 12px 12px;
}
.banner-left {
  flex: 1;
  padding-left: 60px;
}
.banner-left h1 {
  font-size: 32px;
  font-weight: bold;
  margin-bottom: 18px;
}
.banner-left .desc {
  color: #555;
  font-size: 16px;
  margin-bottom: 32px;
}
.banner-btns {
  margin-top: 8px;
}
.banner-right {
  flex: 1;
  display: flex;
  justify-content: center;
}
.banner-img {
  width: 340px;
  height: 220px;
  object-fit: cover;
  border-radius: 12px;
  box-shadow: 0 2px 12px #dbeafe;
}
.section {
  max-width: 1200px;
  margin: 48px auto 0 auto;
  padding: 0 24px;
}
.section-title {
  text-align: center;
  font-size: 24px;
  font-weight: bold;
  margin-bottom: 32px;
}
.category-list {
  display: flex;
  justify-content: space-between;
  margin-bottom: 32px;
}
.category-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 8px #f0f1f3;
  padding: 24px 18px 18px 18px;
  width: 260px;
  min-width: 240px;
  text-align: left;
  transition: box-shadow 0.2s, transform 0.2s;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.category-card:hover {
  box-shadow: 0 8px 24px #e3e8f0;
  transform: translateY(-6px);
}
.cat-img-large {
  width: 240px;
  height: 160px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 16px;
}
.cat-title {
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 8px;
  color: #222;
}
.cat-desc {
  color: #888;
  font-size: 15px;
}
.demand-list {
  display: flex;
  gap: 40px;
  justify-content: space-between;
}
.demand-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 8px #f0f1f3;
  width: 340px;
  min-width: 300px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: box-shadow 0.2s, transform 0.2s;
  cursor: pointer;
}
.demand-card:hover {
  box-shadow: 0 8px 24px #e3e8f0;
  transform: translateY(-6px);
}
.demand-img-large {
  width: 340px;
  height: 180px;
  object-fit: cover;
}
.demand-info {
  padding: 18px 18px 14px 18px;
}
.demand-title {
  font-size: 17px;
  font-weight: bold;
  margin-bottom: 8px;
  color: #222;
}
.demand-desc {
  color: #666;
  font-size: 15px;
  margin-bottom: 12px;
}
.demand-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #888;
  font-size: 14px;
}
.demand-price {
  color: #1976d2;
  font-weight: bold;
  font-size: 16px;
}
.demand-time {
  color: #aaa;
  font-size: 14px;
  text-align: right;
}
.footer {
  background: #222;
  color: #eee;
  padding: 36px 0 0 0;
  margin-top: 60px;
}
.footer-main {
  display: flex;
  justify-content: center;
  gap: 80px;
  max-width: 1200px;
  margin: 0 auto;
  padding-bottom: 24px;
}
.footer-col {
  min-width: 120px;
}
.footer-title {
  font-weight: bold;
  margin-bottom: 10px;
  font-size: 15px;
}
.footer-link {
  color: #bbb;
  font-size: 14px;
  margin-bottom: 6px;
  cursor: pointer;
}
.footer-link:hover {
  color: #fff;
}
.footer-copy {
  text-align: center;
  color: #888;
  font-size: 13px;
  padding: 12px 0 16px 0;
  border-top: 1px solid #333;
  margin-top: 12px;
}
</style>
